package com.dingding.common.core.config;

import org.apache.log4j.Logger;

/**
 * 
 * @ClassName: RedisConfig 
 * @Description:Redis缓存访问相关配置
 * @author CHEHAUNBO 
 * @date 2016年5月26日 上午11:52:59
 * 
 */
public class RedisConfig extends AbstractConfig {

	private Logger log = Logger.getLogger(RedisConfig.class);

	
	
	// Rdis环境 默认为生产环境
	private boolean env_redis = true;

	// Redis服务器HOST
	private static String HOST = Constants.JEDIS_PRODUCE_PATH;

	// Redis的端口号，所以默认为生产端口
	private static int PORT = Constants.JEDIS_PRODUCE_PORT;

	// 访问密码
	private static final String AUTH_PWD = Constants.REDIS_AUTH_PWD;

	/**
	 * 初始化配置
	 * @Title: intitalConfigValue 
	 * @author CHEHAUNBO
	 * 
	 */
	@Override
	public void intitalConfigValue() {

		boolean flag = prop.getBoolean("env_redis");

		if (!flag) { // 测试环境
			env_redis = flag;
			HOST = Constants.JEDIS_TEST_PATH;
			PORT = Constants.JEDIS_TEST_PORT;
		}

		log.info("正在初始化Redis相关配置！初始化后的值：" + toString());
	}

	public boolean isEnv_redis() {
		return env_redis;
	}

	public void setEnv_redis(boolean env_redis) {
		this.env_redis = env_redis;
	}

	public static String getHOST() {
		return HOST;
	}

	public static void setHOST(String hOST) {
		HOST = hOST;
	}

	public static int getPORT() {
		return PORT;
	}

	public static void setPORT(int pORT) {
		PORT = pORT;
	}

	public static String getAuthPwd() {
		return AUTH_PWD;
	}

	public String toString() {

		return "环境：" + env_redis + "[HOST]:" + HOST + "[AUTH_PWD]:" + AUTH_PWD;

	}
	
	

}
